//公共
import myHeader from "/pages/headerfoot/pages/header.vue"
//表格
import uniForms from "/uni_modules/uni-forms/components/uni-forms/uni-forms.vue";
//语言
import Lang from '@/utils/lang.js';
//公共公益方法
import commonBenefit from '@/common/commonbenefit.js';
//公共方法
import Base from '@/common/base.js';
//微信api
import weChat from '@/lib/wechat.js';
//登录api
import Login from '@/lib/login.js';
//用户
import User from '@/lib/user.js';
//公共底部
import Tabbar from "/pages/headerfoot/pages/benefitfooter.vue";
//cache缓存
import Cache from '@/utils/cache.js';

export default {
	components: {
		myHeader,
		uniForms,
		Tabbar
	},
	data() {
		return {
			informationfilling: Lang.lang.informationfilling,
			lang: Lang.lang, //语言1
			code: '', //激活码
			ifshow: true, //是否显示
			page: 1, //页数
			codelist: [], //激活码列表
		}
	},
	// 分享到朋友
	onShareAppMessage(res) {
		weChat.onShareAppMessage(Lang.lang.benefittitle, Lang.lang.ShareAppMessagedesc, commonBenefit
			.automaticurl(
				'benefitindex'));
	},
	// 分享到朋友圈
	onShareTimeline(res) {
		weChat.onShareTimeline(Lang.lang.benefittitle, commonBenefit.automaticurl('benefitindex'));
	},
	onReachBottom() {
		var that = this;
		that.page = that.page + 1;
		that.getcodelist();
	},
	onShow() {
		var that = this;
		that.codelist =[];
		that.ifreglogin();
		that.getcodelist();
	},
	methods: {
		//判断是否需要注册或者登录与其他
		async ifreglogin() {
			var that = this;
			//注册
			await Base.globalauthorization();
		},
		//得到激活码
		async getcodelist() {
			var that = this;
			var data = {};
			data['page'] = that.page;
			data['user_id'] =Cache.get('userid');
			commonBenefit.getWelfareCdkeyLogApiMethod(data).then(res => {
				if (res) {
					  that.codelist = that.codelist.concat(res.data); //赛事参赛列表
				}
			});
		},
	}
}